package practice;

import java.util.Scanner;

public class 登录系统 {
    public static void main(String[] args) {
        Userpass user = new Userpass();
        int a = 0;
        while (a != 3) {
            Scanner sc = new Scanner(System.in);
            System.out.printf("请输入账号：");
            String inuser = sc.next();
            System.out.println();
            System.out.printf("请输入密码：");
            String inpass = sc.next();
            if (user.tesetLogin(inuser, inpass)) {
                System.out.println("登录成功");
                break;
            } else {
                System.out.println("登录失败");
                a++;
            }
        }

    }
}

class Userpass {
    private String username = "tian";
    private String password = "123456";

    public Userpass() {

    }

    public Userpass(String username, String password) {
        this.username = username;
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public boolean login(String username, String password) {
        return username.equals(this.username) && password.equals(this.password);
    }
    public boolean tesetLogin(String username, String password) {
        return username == this.username && password == this.password;
    }
}
